//
//  SACategoryCell.m
//  saasRetail
//
//  Created by ice on 2025/3/29.
//

#import "SACategoryCell.h"
#import "SAServiceMarketModel.h"

@interface SACategoryCell ()

@property (nonatomic, strong) UIImageView *iconImageV;
@property (nonatomic, strong) UILabel *iconNameLab;
@property (nonatomic, strong) UILabel *tipLab;

@end

@implementation SACategoryCell
-(instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAServiceMarketModel *)model {
    _model = model;
    
    [self.iconImageV sd_setImageWithURL:[NSURL URLWithString:model.icon]];
    self.iconNameLab.text = model.menuName;
    if (model.descriptionStr.length > 0) {
        self.tipLab.text = model.descriptionStr;
        self.tipLab.hidden = NO;
    } else {
        self.tipLab.hidden = YES;
    }
}

#pragma mark - initUI
-(void)initUI {
    [self.contentView addSubview:self.iconImageV];
    [self.contentView addSubview:self.iconNameLab];
    [self.contentView addSubview:self.tipLab];
}

#pragma mark - lazy
-(UIImageView *)iconImageV {
    if (!_iconImageV) {
        _iconImageV = [[UIImageView alloc] initWithFrame:CGRectMake(kScaleNum(17), kScaleNum(9), kScaleNum(47), kScaleNum(47))];
    }
    return _iconImageV;
}

-(UILabel *)iconNameLab {
    if (!_iconNameLab) {
        _iconNameLab = [[UILabel alloc] initWithFrame:CGRectMake(0, kScaleNum(61), kScaleNum(81), kScaleNum(20))];
        _iconNameLab.textColor = kBlackColor;
        _iconNameLab.textAlignment = NSTextAlignmentCenter;
        _iconNameLab.font = kFont(13);
    }
    return _iconNameLab;
}

-(UILabel *)tipLab {
    if (!_tipLab) {
        _tipLab = [[UILabel alloc] initWithFrame:SARectMake(50, 5, 102, 15)];
        _tipLab.font = kFont(13);
        _tipLab.textAlignment = NSTextAlignmentCenter;
        _tipLab.textColor = [UIColor whiteColor];
        _tipLab.text = @"";
        _tipLab.backgroundColor = [UIColor redColor];
        _tipLab.layer.masksToBounds = YES;
        _tipLab.layer.cornerRadius = kScaleNum(8);
        _tipLab.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMaxYCorner;
    }
    return _tipLab;
}

@end
